package ink.zhaohui.javaStudy.rules;

import java.util.*;
import org.jeasy.rules.annotation.*;
import org.jeasy.rules.api.Facts;

@Rule(name = "ageRule", description = "age rule description", priority = 1)
public class Age {
    @Condition
    public boolean condition(@Fact("age") Integer age,@Fact("code") List<String> code) {
        //my rule conditions
        if(age>=18){
            System.out.println("o m.");
            code.add("001");
            return false;
        }
        System.out.println("y m.");
        return true;
    }

    @Action(order = 1)
    public void action(Facts facts) throws Exception {
        //my actions
        Integer age=(Integer)facts.get("age");
        System.out.println("m a "+age+".");
    }
}